package com.tcxhb.job.core.schedule.router;

import com.tcxhb.job.dao.dataobject.JobMachineDO;
import com.tcxhb.job.core.service.job.JobMachineService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @Auther: tcxhb
 * @Date: 2023/11/18
 */
public abstract class BaseRouter implements MachineRouter {
    /**
     * 根据应用路由
     *
     * @param appName
     * @return
     */
    @Autowired
    private JobMachineService machineService;

    @Override
    public List<JobMachineDO> routeByApp(int num, String appName) {
        List<JobMachineDO> machineList = machineService.getOnlineByCache(appName);
        if (machineList == null) {
            return new ArrayList<>();
        }
        //
        return this.route(num, machineList);
    }

}
